<?php

namespace app\common\model;

use think\Model;

class TeacherMoneyLog extends BaseModel
{
    protected $autoWriteTimestamp = 'int';
    protected $createTime = 'createtime';
    protected $updateTime = 'updatetime';

    /**
     * 添加明细
     */
    public static function add($teacher, $money, $source, $sourceId = 0)
    {
        $data = [
            'teacher_id' => $teacher->teacher_id,
            'money' => $money,
            'before_money' => $teacher->money,
            'after_money' => $teacher->money + $money,
            'source_id' => $sourceId,
            'source' => $source
        ];
        return self::create($data);
    }

}
